package com.yanqu.road.entity.activity.shuihu.config;

import com.yanqu.road.entity.FieldTypeAnnotation;
import com.yanqu.road.utils.property.Property;
import com.yanqu.road.utils.property.PropertyHelper;
import com.yanqu.road.utils.string.StringUtils;

import java.math.BigInteger;
import java.util.List;

@FieldTypeAnnotation(tableName = "t_s_activity_shuihu_comb")
public class ShuiHuCombConfig {

    @FieldTypeAnnotation
    private int activityId;
    @FieldTypeAnnotation
    private int id;
    @FieldTypeAnnotation
    private String condition; // 组合条件
    @FieldTypeAnnotation
    private String reward;
    @FieldTypeAnnotation
    private int maxTimes; // 兑换次数上限
    @FieldTypeAnnotation
    private String name;
    @FieldTypeAnnotation
    private int sort;

    public int getActivityId() {
        return activityId;
    }

    public void setActivityId(int activityId) {
        this.activityId = activityId;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getCondition() {
        return condition;
    }

    public void setCondition(String condition) {
        // [1000|1001|1002] => [1000=1;1002=1;1003=1]
        List<Integer> list = StringUtils.stringToIntegerList(condition, "\\|");
        Property property = new Property();
        for (Integer cardId : list) {
            property.addProperty(cardId, BigInteger.ONE);
        }
        this.condition = PropertyHelper.parsePropertyToString(property);
    }

    public String getReward() {
        return reward;
    }

    public void setReward(String reward) {
        this.reward = reward;
    }

    public int getMaxTimes() {
        return maxTimes;
    }

    public void setMaxTimes(int maxTimes) {
        this.maxTimes = maxTimes;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getSort() {
        return sort;
    }

    public void setSort(int sort) {
        this.sort = sort;
    }
}
